import GoLuckDraw2 from "./GoLuckDraw2";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    public AwardNode: cc.Node;         //奖励父节
    public LuckDraw: GoLuckDraw2;       //旋转组件

    public rewardCount: number = 14;  
    private curIndex: number = 0;    //当前奖励下标
    private tagetIndex: number = 0;  //目标奖励下标
    private reawadArr: Array<Number> = [0, 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12, 13];  //奖品名称


    onLoad () {
        this.AwardNode = cc.find("ZhuanPanRoot/RewardRoot", this.node);
        this.LuckDraw = cc.find("ZhuanPanRoot", this.node).getComponent(GoLuckDraw2);
    }

    start () {
        //
    }

    private isTurnIng = false;
    public BtnCallBack() {
        if (this.isTurnIng) {
            return;
        }
        this.isTurnIng = true;

        let awardIndex = Math.floor(Math.random() * this.rewardCount);
        this.tagetIndex = awardIndex;

        console.log("========>>>>", awardIndex, this.reawadArr[awardIndex]);

        this.LuckDraw.StartLuckDraw(this, this.curIndex, this.tagetIndex, 3, 2);
        this.LuckDraw.CompleteCallBack = () => {
            this.curIndex = this.tagetIndex;
            this.isTurnIng = false;
        }
    }
}